<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>微博首页</h1>
<div id="v_div">
    <div v-if="user==''">
        <a href="/login.html">登入</a>
        <a href="/reg.html">注册</a>
    </div>
    <div>
        <a href="/send.html">发微博</a>
        <a href="#" @click="logout()">退出登入</a>
    </div>
</div>

<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v=new Vue({
        el:"v_div",
        data:{
            user:"",
            arr:[]
        },
        created:function () {
            axios.get("/checkLogin").then(function (response) {
                v.user=response.data
            })
            axios.get("/select").then(function (response) {
                v.arr=response.data

            })
        },
        methods:{
            logout:function () {
                if (confirm("确定退出吗")){
                axios.get("/logout").then(function (response) {
                    location.reload();
                })
                }
            }
        }

    })
</script>
</body>
</html>